3. Setting up WebWork
3.1 Configuring actions, results, and interceptors
3.1.1 Overview of terminology
- actions
- 웹워크의 핵심(core)이며, 웹기반의 어플리케이션 로직을 구현 한다.
- action에서는 com.opensymphony.xwork.ActionSupport를 상속해야 한다.
- results
- 하나의 액션의 실행(excute)이 끝날 때마다 결과 코드를 반환한다.
- 여러가지 다양한 result를 지원한다.(JSP, Velocity, or FreeMarker)
- 여러가지 result type을 지원 한다.(dispather,rediect)
- interceptors
- Surrounding the execution of an action and its result is an interceptor.
- 주로 action과 result의 시작과 끝으로 실행되고 메소드를 실행 시킬지 말지 결정할수 있다.
- 여러개의 interceptors를 interceptor stack으로 지정하여 사용 할 수 있다.
- Actions에 대한 설명은 위 링크를 참고하세요.
3.1.3 Results
- Login action의 return 값이 input이면 login.jsp 실행 success명 /secure/dashboard.action redirect실행
- result types에 대해서는 뒷 부분에서 자세히 다룰 예정임
<xwork>
<include name="webwork-default.xml"/>
<package name="default" extends="webwork-default">
<default-interceptor-ref name="defaultStack"/>
<action name="login" class="org.hibernate.auction.web.actions.users.Login">
<result name="input">login.jsp</result>
<result name="success" type="redirect">/secure/dashboard.action</result>
</action>
</package>
</xwork>
Reducing configuration duplication with global result mappings
- global-results를 사용하여 여러 액션에서 공통으로 사용할 수 있는 result를 지정한다.
- 'login'이면 /login!default.action 실행 'unauthorized'면 unauthorized.jsp 실행
<package name="default" extends="webwork-default">
<global-results>
<result name="login" type="redirect">/login!default.action</result>
<result name="unauthorized">/unauthorized.jsp</result>
</global-results>
</package>
3.1.4 Interceptors
- Interceptors는 action 과 result의 실행 전, 후에 호출된다.
- interceptors의 그룹을 stack으로 지정하여 사용 할 수 있다.
interceptor와 interceptor stacks
<interceptors>
<interceptor name="params" class="com.opensymphony.xwork.interceptor.ParametersInterceptor"/>
<interceptor name="fileUpload" class="com.opensymphony.webwork.interceptor.FileUploadInterceptor"/>
<interceptor-stack name="myStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servlet-config"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="debugging"/>
<interceptor-ref name="model-driven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="static-params"/>
<interceptor-ref name="params"/>
</interceptor-stack>
</interceptors>
- Listing 3.12 The login action, configured to use the myStack interceptor stack
<action name="login" class="org.hibernate.auction.web.actions.users.Login">
<interceptor-ref name="myStack"/>
<result name="input">login.jsp</result>
<result name="success" type="redirect">/secure/dashboard.action</result>
</action>
- Advanced configuration은 위 링크를 참고 하세요
3.3 Other configuration files
3.3.1 Web-app configuration: web.xml
3.3.2 Feature configuration: webwork.properties
문서에 대하여